<%@ page contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
<<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
</head>

<body>
<input type="text" id="name">
<input type="text" id="author_name">
<button id="submit">提交</button>
</body>

</html>
<script>
    $(function() {
        $("#submit").click(function() {
             var obj = new Object();
            var book = new Object();
            book.name = $("#name").val();
            book.id = $('#author_name').val();
            book.author_id="zuozheid";
             var author = new Object();
             author.authorId = "zuozhe3346";
             author.authorChName = "zuozhe";
             obj.book = book;
             obj.author = author;
             var arr = [book,author];
             var str = JSON.stringify(arr);
             console.log(str);
            // $.post("http://localhost:8888/book/get", book, function(res) {
            //     console.log(res);

            // },'json')

            $.ajax({
                url: "http://localhost:8888/book/get",
                type: "POST",
                data: JSON.stringify(book),
                dataType: "json",
                contentType: 'application/json;charset=UTF-8',
                success: function(data) {
                    alert("request success ! ");
                }
            });


        });
    });
</script>